import { getI18nByKeys } from '@/utils/i18n'
import store from '@/store'
export default{
  data() {
    return {
      i18Keys: [],
      i18Meaning: {}
    }
  },
  created() {
    if (this.language) {
      this.getI18()
    }
  },
  methods: {
    getI18: function(keys) {
      const keyLs = this.i18Keys || keys
      if (keyLs && keyLs.length !== 0) {
        getI18nByKeys(this.i18Keys).then(response => {
          const tmp = response
          this.i18Keys.forEach(element => {
            if (!tmp[element]) {
              tmp[element] = element
            }
          })
          this.i18Meaning = tmp
        })
      }
    }

  },
  computed: {
    _$Z() {
      return this.i18Meaning
      // return this.$store.getters.i18Meaning
    },
    language() {
      return store.getters.language
    }
  },
  watch: {
    i18Keys() {
      this.getI18()
    }
  }
}
